<?php

class Mithos_Template extends Smarty {

    public function __construct($template, $options = array()) {
        parent::__construct();

        $path = isset($options['path']) ? $options['path'] : 'templates';
        $dir = $path . '/' . $template . '/';

        $vars = array(
            'template_dir' => $dir,
            'compile_dir' => $dir . 'compile/',
            'cache_dir' => $dir . 'cache/'
        );

        foreach ($vars as $name => $value) {
            $this->{$name} = $value;
        }

        $this->assign('version', '0.1');
    }

    public function useAction($action) {
        $page = $_GET['do'];
        if (!file_exists($this->template_dir[0] . $page . '/' . $action . '.html') || empty($action)) {
            $fetch = $this->fetch($page . '/home.html');
        } else {
            $fetch = $this->fetch($page . '/' . $action . '.html');
        }
        $this->assign('content_' . $page, $fetch);
    }
}

?>